package com.abc.robot01.room.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.abc.robot01.room.bean.ChatCount

@Dao
interface ChatCountDao {
    @Insert
    fun addChatCount(chatcount: ChatCount): Long

    @Update
    fun update(chatCount: ChatCount)

    /**
     * 查询
     * 通过text得到一个chatcount
     *
     * @param id
     * @return
     */
    @Query("SELECT * FROM CHAT_COUNT WHERE text = :text LIMIT 1")
    fun getChatCount(text: String): ChatCount?

    @Query("SELECT * FROM CHAT_COUNT")
    fun queryAll(): List<ChatCount>

    /**
     * 更新
     *
     * @param text
     * @param totalCount
     * @param weekCount
     * @param dayCount
     */
    @Query("UPDATE CHAT_COUNT SET text = :text, totalcount = :totalCount,weekcount=:weekCount, daycount=:dayCount")
    fun updateChatCount(text: String, totalCount: Int, weekCount: Int, dayCount: Int)

}